<template>
  <div class="products">
      <van-dropdown-menu>
        <van-dropdown-item disabled title="综合" />
        <van-dropdown-item @change="priceChange" title="价格" v-model="value2" :options="option2" />
        <van-dropdown-item  @change="categoryChange"   title="分类" v-model="categoryval" :options="filterCategory" />
      </van-dropdown-menu>
      <van-empty image="search" description="没有更多了" v-if="this.goodsList.length==0"/>
      <SearchProducts :goodsList="goodsList" v-else/>
  </div>
</template>

<script>
import SearchProducts from "./SearchProducts.vue"
export default {
    props:["filterCategory","goodsList"],
    data(){
        return{
            value1: 0,
            value2: 'a',
            categoryval:0,
            option2: [
                { text: '价格由高到低', value: 'desc' },
                { text: '价格由低到高', value: 'asc' },
            ],
        }
    },
    beforeUpdated(){
        this.filterCategory.map(item=>{
            if(item.checked){
                this.categoryval = item.value
                return
            }
        })
    },
    methods: {
        categoryChange(value){
            console.log(value);
            this.$emit('categoryChange',value)
        },
        priceChange(value){
            this.$emit('priceChange',value)
        }
    },
    components:{
        SearchProducts
    }
}
</script>

<style lang="scss" scoped>

</style>